<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html">
<h:head>
	<title>#{msgs.windowMenu}</title>
</h:head>
<h:outputStylesheet library="css" name="bootstrap.css" />
<h:body style="padding-left:10px">
	<h4>#{msgs.users}</h4>

	<h:form>
		<h:dataTable value="#{superMenu.temp}" var="userCred" frame="border"
			rules="all" styleClass="order-table" headerClass="order-table-header"
			rowClasses="order-table-odd-row,order-table-even-row"
			rendered="#{superMenu.login.getActiveUser().isSuperUser()}">

			<h:column style="text-align:center">
				<f:facet name="header">
					<h:outputText value="#{msgs.editColumn}" style="font-weight: bold" />
				</f:facet>
				<h:selectBooleanCheckbox value="#{userCred.editable}"
					onclick="submit()" />
			</h:column>

			<h:column style="text-align:left">
				<f:facet name="header">
					<h:outputText value="#{msgs.username}" style="font-weight: bold" />
				</f:facet>
				<h:inputText id="validUsername" value="#{userCred.username}"
					rendered="#{userCred.editable}" size="5" style="width: 40px"
					validatorMessage="#{msgs.validatorUsername}">
					<f:validateLength minimum="1" />
					<h:message for="validUsername"/>
				</h:inputText>
				<h:outputText value="#{userCred.username}"
					rendered="#{not userCred.editable}" />
			</h:column>

			<h:column style="text-align:left">
				<f:facet name="header">
					<h:outputText value="#{msgs.password}" style="font-weight: bold" />
				</f:facet>
				<h:inputText id="validPassword" value="#{userCred.password}"
					rendered="#{userCred.editable}" size="5" style="width: 40px" 
					validatorMessage="#{msgs.validatorPassword}">
					<f:validateLength minimum="1" />
					<h:message for="validPassword"/>
				</h:inputText>
				<h:outputText value="#{userCred.password}"
					rendered="#{not userCred.editable}" />
			</h:column>

			<h:column style="text-align:left">
				<f:facet name="header">
					<h:outputText value="#{msgs.full}" style="font-weight: bold" />
				</f:facet>
				<h:inputText id="validFullname" value="#{userCred.fullname}"
					rendered="#{userCred.editable}" size="5" style="width: 40px" 
					validatorMessage="#{msgs.validatorFullname}">
					<f:validateLength minimum="1" />
					<h:message for="validFullname"/>
				</h:inputText>
				<h:outputText value="#{userCred.fullname}"
					rendered="#{not userCred.editable}" />
			</h:column>

			<h:column style="text-align:left">
				<f:facet name="header">
					<h:outputText value="#{msgs.eNum}" style="font-weight: bold" />
				</f:facet>
				<h:outputText value="#{userCred.eNumber}"/>
			</h:column>
			<h:column style="text-align:left">
				<f:facet name="header">
					<h:outputText value="#{msgs.delete}" style="font-weight: bold" />
				</f:facet>
				<h:commandButton value="#{msgs.delete}"
					class="btn btn-small btn-danger"
					action="#{superMenu.delete(userCred)}"
					rendered="#{not userCred.isSuperUser()}" />
			</h:column>
		</h:dataTable>
		<br />
		<div class="btn-group">
			<h:commandButton value="#{msgs.add}" class="btn btn-small btn-success"
                          action="#{superMenu.add}" rendered="#{superMenu.login.getActiveUser().isSuperUser()}"/>
			<h:commandButton value="#{msgs.saveChangesButtonText}"
				class="btn btn-small btn-primary" action="#{superMenu.save}" rendered="#{superMenu.login.getActiveUser().isSuperUser()}"/>
			<h:commandButton value="#{msgs.view}"
				class="btn btn-small btn-primary" action="index" />
			<h:commandButton value="Logout" class="btn btn-small btn-warning"
				action="#{superMenu.logout}" />
		</div>
		<br />
		<h:outputText class="alert alert-error" value="Usernames must be unique"
		              style="padding: 6px 3px 6px 4px;vertical-align: -1px;margin-top: 6px;"
		              rendered="#{!superMenu.uniqueUsername}" />
		<br />
		
	</h:form>
</h:body>
</html>
